#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time  : 2019/8/11 17:02
# @Author: Eason
# @File  : json_res.py
# @Desc  :


from django.http import JsonResponse

from .res_code import Code

def json_response(errno=Code.OK, errmsg='', data=None, kwargs=None):
    json_dict = {
        'errno': errno,
        'errmsg': errmsg,
        'data': data
    }
    if kwargs and isinstance(kwargs, dict):
        json_dict.update(kwargs)

    return JsonResponse(json_dict)